#include "base.h"

#ifndef UGLY_HACK_FOR_THOSE_WHO_DONT_KNOW_HOWTO_INSTALL_SDL
#include <SDL/SDL.h>
#else
#include <SDL.h>
#endif


//-----------------------------------------------------------------------------
// Base module initialization
//-----------------------------------------------------------------------------


void base_init(void) //Initialize base module.
{
    log_set_level(LOG_DBG);

    if(SDL_Init(0) == -1)
    {
        log_printf(LOG_ERR, "Couldn't initialize SDL: %s", SDL_GetError());
        exit(EXIT_FAILURE);
    }
    time_get();

    log_puts(LOG_DBG, "Done initializing base module");
    srand(time(NULL));
}

void base_exit(void) //Uninitialize base module.
{
    SDL_Quit();

    log_puts(LOG_DBG, "Done uninitializing base module");
    if(mem_get_nb_allocations() > 0)
    {
        log_printf(LOG_DBG, "Detected %d memory leaks!", mem_get_nb_allocations());
    }
}
